#-*-coding:utf-8-*-
# 
# 
# import urllib2
# 
# 
# request = urllib2.Request("http://www.cnvd.org.cn/flaw/list.htm")
# request.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
# # request.add_header('Accept-Encoding','gzip, deflate')
# request.add_header('Accept-Language', 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3')
# request.add_header('Cache-Control', 'max-age=0')
# request.add_header('Connection', 'keep-alive')
# request.add_header('Host', 'www.cnvd.org.cn')
# 
# request.add_header('Pragma', 'no-cache')
# request.add_header('Referer', 'http://www.cnvd.org.cn/flaw/list.htm')
# # request.add_header('Upgrade-Insecure-Requests', '1')
# request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0')
# request.add_header('Cookie', 'td_cookie=1509858642; __jsluid=5438268a27027883e87e566d30df596d; bdshare_firstime=1494515517367; __jsl_clearance=1494983983.006|0|lhdcqaFJwN9zdKQG62%2BCW5hVsJY%3D; JSESSIONID=CFA336D13672F2C01DDCEB14E640703E')
# 
# response = urllib2.urlopen(request)
# # print type(response.read)
# print response.read()


#封装了之后的写法
import urllib2


def httpget(url):
    request = urllib2.Request(url)
    request.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8')
    request.add_header('Accept-Encoding', 'text/html')
    request.add_header('Accept-Language', 'zh-CN,zh;q=0.8')
    request.add_header('Cache-Control', 'no-cache')
    request.add_header('Connection', 'keep-alive')
    request.add_header('Host', 'www.cnvd.org.cn')

    request.add_header('Pragma', 'no-cache')
    request.add_header('Referer', 'http://www.cnvd.org.cn/flaw/list.htm')
    request.add_header('Upgrade-Insecure-Requests', '1')
    request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0')
    request.add_header('Cookie', '__jsluid=c8eae2afe84bc6a82d2c9f8ed4f3837b; bdshare_firstime=1494470498719; __jsl_clearance=1494983843.996|0|8Mt0KixRkU02pgcP9qpo5AfNwug%3D; JSESSIONID=01A1D39775229FD789A7FC6EF6230B25')

    response = urllib2.urlopen(request)
    return response.read()
print httpget("http://www.cnvd.org.cn/flaw/list.htm")
